import GameLogic as g




##########  

class command:
	
	def __init__(self, keyDict = 0):
		if keyDict == 0:
			self.keyDict = { 146:"uparrow",
			144:"downarrow", 
			13:"return", 
			97:"a", 
			98:"b", 
			99:"c", 
			100:"d", 
			101:"e" }
				
		self.target = 0
		self.keyboard = 0
		pass
		#try to load a keymap otherwise assign defaults
		
	def input(self, keyboard):
		self.keyboard = keyboard
		
	def route(self, textObject):
		self.target = textObject
		
	def check(self): ## Returns a list of the command names
		cpk = self.keyboard.getCurrerntlyPressedKeys()
		cmnds = []
		for entry in cpk:
			if entry[0] in self.keyDict:
				cmnds.append( [ self.keyDict[entry[0] ], entry[1] ] )
		return cmnds
	
	# command object created once at start of game, getting input requires calling command.input to init the keyboard
	# sesnsor, then running check to get the string names of keys (with hit state?)
	#keyboard sensor can return commands or pass input to a input object and check for return
	
	#Clean up the UI.py key check for a list, should be a target?
	
	
	#Think ahead about definable macros, defining keys in general
	
	
	
	